module.exports = function ($scope, noticelist, $modal, noticeinfo, toaster,
	userinfo, getSellerInfoByCode, $state) {

	console.log("%c 居游 %c 做地球上最具互联网性、创新性、专业有爱的团队。 \xa9 2015-%d", 'font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:64px;color:#00bbee;-webkit-text-fill-color:#00bbee;-webkit-text-stroke: 1px #00bbee;', "font-size:12px;color:#999999;", (new Date).getFullYear());

	// //$scope.d = [ [1,6.5],[2,6.5],[3,7],[4,8],[5,7.5],[6,7],[7,6.8],[8,7],[9,7.2],[10,7],[11,6.8],[12,7] ];

	//   $scope.d0_1 = [ [0,7],[1,6.5],[2,12.5],[3,7],[4,9],[5,6],[6,11],[7,6.5],[8,8],[9,7] ];

	//   // $scope.d0_2 = [ [0,4],[1,4.5],[2,7],[3,4.5],[4,3],[5,3.5],[6,6],[7,3],[8,4],[9,3] ];

	//   // $scope.d1_1 = [ [10, 120], [20, 70], [30, 70], [40, 60] ];

	//   // $scope.d1_2 = [ [10, 50],  [20, 60], [30, 90],  [40, 35] ];

	//   // $scope.d1_3 = [ [10, 80],  [20, 40], [30, 30],  [40, 20] ];

	//   // $scope.d2 = [];

	//   // for (var i = 0; i < 20; ++i) {
	//   //   $scope.d2.push([i, Math.sin(i)]);
	//   // }   

	//   // $scope.d3 = [ 
	//   //   { label: "iPhone5S", data: 40 }, 
	//   //   { label: "iPad Mini", data: 10 },
	//   //   { label: "iPad Mini Retina", data: 20 },
	//   //   { label: "iPhone4S", data: 12 },
	//   //   { label: "iPad Air", data: 18 }
	//   // ];

	//   // $scope.refreshData = function(){
	//   //   $scope.d0_1 = $scope.d0_2;
	//   // };

	//   $scope.getRandomData = function() {
	//     var data = [],
	//     totalPoints = 150;
	//     if (data.length > 0)
	//       data = data.slice(1);
	//     while (data.length < totalPoints) {
	//       var prev = data.length > 0 ? data[data.length - 1] : 50,
	//         y = prev + Math.random() * 10 - 5;
	//       if (y < 0) {
	//         y = 0;
	//       } else if (y > 100) {
	//         y = 100;
	//       }
	//       data.push(y);
	//     }
	//     // Zip the generated y values with the x values
	//     var res = [];
	//     for (var i = 0; i < data.length; ++i) {
	//       res.push([i, data[i]])
	//     }
	//     return res;
	//   }

	//    $scope.d4 = $scope.getRandomData();




	//    $scope.hehe = function(){

	//    	alert('hehe');

	//    }


	/* 分页
	 * ========================================= */
	$scope.maxSize = 5;            //最多显示多少个按钮
	$scope.bigCurrentPage = 1;      //当前页码
	$scope.itemsPerPage = 10;         //每页显示几条

	$scope.load = function () {

		var para = {
			pageNo: $scope.bigCurrentPage,
			pageSize: $scope.itemsPerPage
		};

		noticelist.get(para, function (res) {

			if (res.errcode === 0) {
				$scope.objs = res.data.results;
				$scope.bigTotalItems = res.data.totalRecord;
			}
			else {
				toaster.error({title:'',body:res.errmsg});
			}

		});

	};
	$scope.load();


	//打开模态框
	$scope.info = function (id) {

		var modalInstance = $modal.open({
			template: require('../views/noticeinfo.html'),
			controller: 'noticeinfo',
			resolve: {
				id: function () {
					return id;
				},
				noticeinfo: function () {
					return noticeinfo;
				}
			}
		});

		modalInstance.result.then(function () {
			//load();
		}, function () {
			//$log.info('Modal dismissed at: ' + new Date());
		});
	}


	//用户信息
	userinfo().then(function (res) {

		$scope.userobj = res;

		getSellerInfoByCode.get({ 'company_code': $scope.userobj.company_code }, function (res) {
			if (res.errcode === 0) {
				$scope.userobj.balance_price = res.data.balance_price;
			}
			else {
				//alert(res.errmsg);
			}
		});

	});


	$scope.detail = function (obj) {
		console.log(532)
		$state.go('app.trackinfo');
	}



};